package com.bean.library;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Paper {
	protected int paperId;
	protected String paperName;
	protected ArrayList<Subject> subList=null;
	protected float paperScore;
	protected float passScore;
	protected long lastTimeMs;
	protected Date startTime;
	protected Date createTime;
	protected String creatorName;
	protected int submitNum;
	protected int kinds;
	public static final int KINDS_EXAM_PAPER = 1;
	public static final int KINDS_SPARE_PAPER = 2;
	public static final int KINDS_PRACTICE_PAPER = 3;
	
	public int getKinds() {
		return kinds;
	}
	public void setKinds(int kinds) {
		this.kinds = kinds;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getCreatorName() {
		return creatorName;
	}
	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}
	public int getSubmitNum() {
		return submitNum;
	}
	public void setSubmitNum(int submitNum) {
		this.submitNum = submitNum;
	}
	public static final int ISTESTING = 0;
	public static final int NOTBEGIN = 1;
	public static final int FINISHED = 2;
	
	public float getPassScore() {
		return passScore;
	}
	public void setPassScore(float passScore) {
		this.passScore = passScore;
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	protected int startIndex;//前台所需，不理。。。
	
	public int getPaperId() {
		return paperId;
	}
	public void setPaperId(int paperId) {
		this.paperId = paperId;
	}
	public ArrayList<Subject> getSubList() {
		return subList;
	}
	public void setSubList(ArrayList<Subject> subList) {
		this.subList = subList;
	}
	public float getPaperScore() {
		return paperScore;
	}
	public void setPaperScore(float paperScore) {
		this.paperScore = paperScore;
	}
	public long getLastTimeMs() {
		return lastTimeMs;
	}
	public void setLastTimeMs(long lastTimeMs) {
		this.lastTimeMs = lastTimeMs;
	}
	
	
	public int getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public boolean setPaperName(String paperName){
		if(paperName.equals(null))return false;
		this.paperName = paperName;
		return true;
	}
	public Paper(){
		this.startIndex = 0;
	}
	public String getPaperName(){
		return this.paperName;
	}
	public boolean addSubject(Subject subject){
		if(this.subList==null){
			this.subList = new ArrayList<Subject>();
		}
		return this.subList.add(subject);
	}
	public boolean setSubjectList(ArrayList<Subject> list){
		if(this.subList!=null){
			return false;
		}
		this.subList = list;
		return true;
	}
	public ArrayList<Subject> getSubjectList(){
		return this.subList;
	}
	public Subject getSubject(int subjectIndex){
		return this.subList.get(subjectIndex);
	}
	public ArrayList<Subject> getSubjectList(int indexBegin,int pageCount){
		ArrayList<Subject> subjectList = new ArrayList<Subject>();
		int subjectCount = this.subList.size();
		for(int i = indexBegin;i<indexBegin+pageCount&&i<subjectCount;i++){
			subjectList.add(this.subList.get(i));
		}
		return subjectList;
	}
	public Date getFinishDate(){
		Date date = new Date();
		date.setTime(this.startTime.getTime());
		date.setSeconds((int) (this.startTime.getSeconds()+this.lastTimeMs/1000));
		return date;
	}
	public int getTimeStat(){
		Date dateNow = new Date();
		if(this.startTime.after(dateNow)){
			return Paper.NOTBEGIN;
		}
		if(dateNow.after(this.getFinishDate())){
			return Paper.FINISHED;
		}
		return Paper.ISTESTING;
	}
	public Date getDateNow(){
		Date date = new Date();
		return date;
	}
}